package com.admin.action.bookaction;



import com.admin.Action;
import com.admin.service.borservice.BorServiceImpl;
import com.google.gson.Gson;
import com.pojo.BorrowerBean;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

public class AllBorInfoAction extends Action {

    Gson gson = new Gson();

    @Override
    public void execute(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        PrintWriter out=response.getWriter();
        //天啊及
        HttpSession session = request.getSession();
//        System.out.println(session.getAttribute("adminInfo"));
        if(session.getAttribute("adminInfo")==null){
            out.println("<script>parent.window.location.href='error.html';</script>");
            return;
        }
        BorServiceImpl service = new BorServiceImpl();
        List<BorrowerBean> list = service.getAllBorInfo();
        String allBorInfoJson = gson.toJson(list);

        out.print(allBorInfoJson);

    }
}
